<?php

namespace app\store\validate;

use think\Validate;

class CouponValidate extends Validate
{
    protected $rule = [
        'coupon_type' => 'require|integer|in:1,2,3,4',
        'coupon_name' => 'require|max:100',
        'expire_type' => 'require|in:1,2',
        'expire_day' => 'requireIf:expire_type,1',
        'icon' => 'require|max:255',
        'with_amount' => 'float',
        'used_amount' => 'float',
        'start_time' => 'requireIf:expire_type,2',
        'end_time' => 'requireIf:expire_type,2',
        'quota' => 'require|integer',
        'desc' => 'max:255'
    ];


    protected $message = [
        'id.require' => '非法请求',
        'id.integer' => '非法请求',
        'coupon_type.require' => '请选择优惠券类型',
        'coupon_type.in' => '无效的优惠券类型!',
        'coupon_name.require' => '请输入优惠券名称!',
        'icon.require' => '请上传图标!',
        'start_time.requireIf' => '请选择有效开始时间',
        'end_time.requireIf' => '请选择有效结束时间',
        'quota.require' => '请输入优惠券数量!',
    ];

    public function sceneEdit()
    {
    	return $this->only(['id','icon','coupon_name','coupon_type','start_time','end_time','with_amount','used_amount','quota','desc'])
                    ->append('id', 'require|integer');
            
    }   
}